import { useState } from 'react'
import { useRequest } from 'ahooks'
import { getUsername } from './api/request'

// 请求数据 经常出现的 ahooks
// data
// loading 
// error  
function App() {
  const {data:userName,error,loading} = useRequest(getUsername);
  if(error) return <div>failed to load</div>
  if(loading) return <div>loading...</div>
  return (
    <div className="App">
     username:{userName}
    </div>
  )
}

export default App
